package tur.br.moradadosol.control;

import java.util.Collection;

import tur.br.moradadosol.dao.DAOFactory;
import tur.br.moradadosol.model.Hospede;

public class HospedeControl {
	
	public String gravar(Hospede hospede) throws Exception {
		
		String msgResult = "";
		
		if(hospede.getCodigo() > 0) {
			DAOFactory.getDAOFactory().getHospedeDAO().update(hospede);
			msgResult = "message.hospede.atualizacao.success";
		} else {
			DAOFactory.getDAOFactory().getHospedeDAO().insert(hospede);
			msgResult = "message.hospede.cadastro.success";
		}
		
		return msgResult;
	}
	
	public void deletar(int codigo) throws Exception {
		DAOFactory.getDAOFactory().getHospedeDAO().delete(codigo);
	}
	
	public Hospede getHospedeByCodigo(int codigo) throws Exception {
		return DAOFactory.getDAOFactory().getHospedeDAO().getHospedeByCodigo(
			codigo);
	}
	
	public Collection getHospedes() throws Exception {
		return DAOFactory.getDAOFactory().getHospedeDAO().getHospedes();
	}
	
	public Collection getHospedesByNome(String nome) throws Exception {
		return DAOFactory.getDAOFactory().getHospedeDAO().getHospedesByNome(
			nome);
	}
}
